package rpg.engine.model;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import rpg.client.model.Dialog;
import rpg.util.Objects;

public class DialogInfo {
	public static class Builder {
		private boolean onceOnly = true;

		private boolean intro = true;

		private Dialog dialog = null;
		private final List<GameEffect> effects = new ArrayList<GameEffect>();

		private final List<When> whens = new ArrayList<When>();

		public Builder() {
			super();
		}

		public DialogInfo build() {
			return new DialogInfo(this);
		}

		public Builder dialog(final Dialog d) {
			dialog = d;
			return this;
		}

		public Builder effect(final GameEffect ge) {
			effects.add(ge);
			return this;
		}

		public Builder intro(final boolean b) {
			intro = b;
			return this;
		}

		public Builder once(final boolean b) {
			onceOnly = b;
			return this;
		}

		public Builder when(final When w) {
			whens.add(w);
			return this;
		}
	}

	private final boolean onceOnly;
	private final boolean intro;

	private final Dialog dialog;
	private final List<GameEffect> effects;

	private final List<When> whens;

	public DialogInfo(final Builder b) {
		super();
		dialog = Objects.requireNonNull(b.dialog, "DialogInfo.dialog");
		effects = Collections.unmodifiableList(b.effects);
		intro = b.intro;
		whens = Collections.unmodifiableList(b.whens);
		onceOnly = b.onceOnly;
	}

	public Dialog getDialog() {
		return dialog;
	}

	public List<GameEffect> getEffects() {
		return effects;
	}

	public List<When> getWhens() {
		return whens;
	}

	public boolean isIntro() {
		return intro;
	}

	public boolean isOnceOnly() {
		return onceOnly;
	}

	@Override
	public String toString() {
		return "DialogInfo: " + getDialog();
	}
}
